<!DOCTYPE html>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<script src='../../resources/gesture-util.js'></script>

<style>
  #same-page {
    position: absolute;
    top: 2000px;
  }
</style>

<a href='./same-page-navigate.html' id='same-page'>link to self</a>

<script>
let same_page_navigate_test = async_test("Ensure that the scroll position is correct when we navigate to same page after scale(zoom-in/zoom-out)");

same_page_navigate_test.step(async () => {
  await waitForCompositorCommit();
  // exit in second load, using scale to detect
  if (internals.pageScaleFactor() == 2) {
    assert_equals(scrollX, 0);
    assert_equals(scrollY, 0);
    same_page_navigate_test.done();
    return;
  }

  internals.setPageScaleFactor(2);
  await waitForCompositorCommit();

  scrollTo(0, 10000);

  // this clicks on the link which causes a reload of this page.
  document.getElementById('same-page').click();
});
</script>